home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / ste / 50play.lzh / PR50TTP6.S < prev    next >
Text File  |  1992-11-28  |  54KB  |  2,429 lines

  1. ;-----------------------------------------------------------------------;
  2. ;                                    ;
  3. ;               TTP .MOD Player                ;
  4. ;               7 Bit Ste/TT Pro-Tracker 2.1A Driver          ;
  5. ;          (C) October/November 1992 Griff of Electronic Images        ;
  6. ;                                    ;
  7. ; - 50 khz stereo sound, with microwire control.            ;
  8. ; - The ONLY player in the whole wide world to emulate TEMPO properly.    ;
  9. ; - SEE DOC file for furthur info.                    ;
  10. ;-----------------------------------------------------------------------;
  11. ; Quick notes about this source.                    ;
  12. ; - Assemble using DEVPAC 2 or 3.                    ;
  13. ; - This replay is NOT fast and nor should it be.             ;
  14. ; - It is designed for QUALITY and ACCURATE replay of ProTracker MODS.    ;
  15. ; - It doe NOT pad samples and so doesn't waste any setup time/memory.    ;
  16. ; - If you use it, then please credit me.                ;
  17. ;-----------------------------------------------------------------------;
  18.  
  19. test        EQU 0            ; if test=1 then run from assember
  20.                     ; (with a pre-included module)
  21. bufsize     EQU 5500        ; maximum size of buffer
  22.                     ; (when tempo =32)
  23. dmamask     EQU %00000011        ; STE dmamask for 50khz
  24.  
  25.         OPT O+,OW-
  26.  
  27. letsgo        
  28.         IFEQ test
  29.         MOVEA.L 4(A7),A5
  30.         LEA $80(A5),A5            ; -> length,filename
  31.         ELSEIF
  32.         LEA testfile,A5            ;  if in testmode
  33.         ENDC                ; then -> testfilename
  34.  
  35.         MOVE.B (A5)+,D0         ; get filename length.
  36.         BEQ mustinstall            ; no filename given?
  37.         LEA filename(PC),A4
  38. .lp        MOVE.B (A5)+,(A4)+        
  39.         SUBQ.B #1,D0
  40.         BNE.S .lp
  41.         CLR.B (A4)            ; terminate filename
  42.  
  43.         MOVE.L 4(SP),A5
  44.         MOVE.L $C(A5),A4
  45.         ADD.L $14(A5),A4
  46.         ADD.L $1C(A5),A4
  47.         LEA $100(A4),A4            ; proggy size+basepage
  48.         PEA (A4)
  49.         PEA (A5)
  50.         CLR -(SP)
  51.         MOVE #$4A,-(SP)
  52.         TRAP #1                ; reserve some memory
  53.         LEA 12(SP),SP
  54.         CLR.L -(SP)
  55.         MOVE #$20,-(SP)    
  56.         TRAP #1                ; supervisor mode
  57.         ADDQ.L #6,SP
  58.         MOVE.L D0,oldsp
  59.         MOVE.L USP,A0
  60.         MOVE.L A0,oldusp        ; save user stack ptr.
  61.         LEA my_stack,SP            ; our own stack.
  62.  
  63.         DC.W $A00A            ; hide mouse
  64.         BSR set_screen            ; setup the screen
  65.  
  66.         BSR SoundTest            ; check for dma sound
  67.         TST.L D1            ; if this is an old ST
  68.         BEQ wrongST_error        ; then quit out!
  69.  
  70.         MOVE #$777,D7            ;;; in future
  71. .fadedownfirst    BSR Wait_Vbl            ;;; will use o.s
  72.         BSR Wait_Vbl            ;;; set colour.
  73.         MOVE.W D7,$FFFF8240.W
  74.         SUB #$111,D7
  75.         BGE.S .fadedownfirst
  76.         MOVE.L #$00000777,$FFFF8240.W     ;;;
  77.         MOVE.L #$00000777,$FFFF8244.W    ;;;
  78.  
  79.         BSR load_mod            ; load the module
  80.         TST.B errorflag
  81.         BNE load_error            ; exit if load error
  82.         BSR print_mainscr        ; print main screen
  83.         BSR set_microwire        ; setup micrwire
  84.         BSR Wait_Vbl
  85. .goformusic    BSR init_ints            ; and kill ints
  86.         MOVEQ #1,D0
  87.         MOVEQ #0,D1
  88.         BSR Init_ST            ; install music
  89.  
  90. ; Music playing, key selection loop follows(microwire control)
  91.  
  92. .waitk        BSR Wait_VblNG    
  93.         BSR Wait_VblNG    
  94.         BSR Wait_VblNG    
  95.         BSR print_tempo
  96.         BSR microwire_cont        ; microwire keyboard control
  97.         MOVE.B key(PC),D0
  98.         CMP.B #$14+$80,D0        ; t pressed and released?
  99.         BNE.S .nottempo    
  100.         BSR toggle_tempo        ; yes then toggle tempo
  101.         CLR.B key
  102. .nottempo    CMP.B #$39+$80,D0        ; space exits.
  103.         BNE .waitk
  104.  
  105.         BSR stop_music
  106.         BSR restore_ints        ; restore gem..
  107.  
  108. exit        BSR restore_screen    
  109. exitloaderr    DC.W $A009
  110.         MOVE.L oldsp(PC),-(SP)
  111.         MOVE #$20,-(SP)    
  112.         TRAP #1                ; user mode
  113.         ADDQ.L #6,SP
  114. redir        PEA dummy(PC)
  115.         MOVE.W #$4e,-(SP)
  116.         TRAP #1
  117.         ADDQ.L #6,SP
  118.         CLR.W -(SP)            ; Get dir.
  119.         PEA dir
  120.         MOVE.W #$47,-(SP)
  121.         TRAP #1
  122.         ADDQ.L #8,SP
  123.         CLR -(SP)
  124.         TRAP #1
  125.  
  126. ;-------------------------------------------------------------------------
  127. ; A few error handlers.
  128.  
  129. ; NO DMA Sound so can't use this player.
  130.  
  131. wrongST_error    PEA wrongST_err_txt(PC)
  132.         MOVE.W #9,-(SP)
  133.         TRAP #1
  134.         ADDQ.L #6,SP
  135.         MOVE.W #7,-(SP)
  136.         TRAP #1
  137.         ADDQ.L #2,SP
  138.         BRA exit
  139.  
  140. load_error    BSR restore_screen    
  141.         CMP.L #-33,error_no
  142.         BNE.S .not_fnf
  143.         PEA filenf_errortxt(PC)
  144.         BRA.S .cont
  145. .not_fnf    PEA load_errortxt(PC)
  146. .cont        MOVE.W #9,-(SP)
  147.         TRAP #1
  148.         ADDQ.L #6,SP
  149.         MOVE.W #7,-(SP)
  150.         TRAP #1
  151.         ADDQ.L #2,SP
  152.         BRA exitloaderr
  153.  
  154. ; No FILENAME was passed error - so tell 'em how to install !!
  155.  
  156. mustinstall    DC.W $A00A
  157.         PEA installtxt(PC)
  158.         MOVE.W #9,-(SP)
  159.         TRAP #1
  160.         ADDQ.L #6,SP
  161.         MOVE.W #7,-(SP)
  162.         TRAP #1
  163.         ADDQ.L #2,SP
  164.         DC.W $A009
  165.         BRA.S redir
  166.  
  167. installtxt    DC.B 27,"E"
  168.         DC.B "You must install this program as an",10,13
  169.         DC.B "application on the Gem desktop,",10,13
  170.         DC.B "OR Type the Module Name if you are",10,13
  171.         DC.B "running this from a command line!",10,13
  172.         DC.B "Press any key.",10,13,0
  173.  
  174. load_errortxt    DC.B 27,"E"
  175.         DC.B "Load Error(disk error?)",10,13
  176.         DC.B "Press any key.",10,13,0
  177.  
  178. filenf_errortxt    DC.B 27,"E"
  179.         DC.B "File Not Found",10,13
  180.         DC.B "Press any key.",10,13,0
  181.     
  182.  
  183. wrongST_err_txt    DC.B 27,"E"
  184.         DC.B "You must have an Ste,Mega Ste or TT",10,13
  185.         DC.B "to run this module player..(sorry!)",10,13
  186.         DC.B "Press any key.",10,13,0
  187.         EVEN
  188.  
  189. ;-------------------------------------------------------------------------
  190. ; Subroutines for interrupts and replay.
  191.  
  192. ; Save mfp vectors and ints and install our own.(very 'clean' setup rout)
  193.  
  194. init_ints    MOVEQ #$13,D0            ; pause keyboard
  195.         BSR Writeikbd            ; (stop from sending)
  196.         MOVE #$2700,SR
  197.         LEA old_stuff+32(PC),A0
  198.         MOVE.B $FFFFFA07.W,(A0)+
  199.         MOVE.B $FFFFFA09.W,(A0)+
  200.         MOVE.B $FFFFFA13.W,(A0)+
  201.         MOVE.B $FFFFFA15.W,(A0)+    ; Save mfp registers 
  202.         MOVE.B $FFFFFA19.W,(A0)+
  203.         MOVE.B $FFFFFA1F.W,(A0)+
  204.         MOVE.L $70.W,(A0)+
  205.         MOVE.L $B0.W,(A0)+
  206.         MOVE.L $118.W,(A0)+
  207.         MOVE.L $134.W,(A0)+
  208.         CLR.B $fffffa07.W
  209.         MOVE.B #$40,$fffffa09.W
  210.         CLR.B $fffffa13.W
  211.         MOVE.B #$40,$fffffa15.W
  212.         BCLR.B #3,$fffffa17.W        ; software end of int.
  213.         LEA my_vbl(PC),A0
  214.         MOVE.L A0,$70.W            ; set our vbl
  215.         LEA key_rout(PC),A0
  216.         MOVE.L A0,$118.W        ; and our keyrout.
  217.         LEA supers(PC),A0
  218.         MOVE.L A0,$B0.W
  219.         CLR key            
  220.         MOVE #$2300,SR
  221.         MOVEQ #$11,D0            ; resume sending
  222.         BSR Writeikbd
  223.         MOVEQ #$12,D0            ; kill mouse
  224.         BSR Writeikbd
  225.         BSR flush
  226.         RTS
  227.  
  228. supers        BCHG #13-8,(SP)            ; toggle super
  229.         RTE
  230.  
  231. ; Restore mfp vectors and ints.
  232.  
  233. restore_ints    MOVE.L oldusp(PC),A0
  234.         MOVE.L A0,USP
  235.         MOVEQ #$13,D0            ; pause keyboard
  236.         BSR Writeikbd            ; (stop from sending)
  237.         MOVE #$2700,SR
  238.         LEA old_stuff+32(PC),A0
  239.         MOVE.B (A0)+,$FFFFFA07.W
  240.         MOVE.B (A0)+,$FFFFFA09.W
  241.         MOVE.B (A0)+,$FFFFFA13.W
  242.         MOVE.B (A0)+,$FFFFFA15.W    ; restore mfp
  243.         MOVE.B (A0)+,$FFFFFA19.W
  244.         MOVE.B (A0)+,$FFFFFA1F.W
  245.         MOVE.L (A0)+,$70.W
  246.         MOVE.L (A0)+,$B0.W
  247.         MOVE.L (A0)+,$118.W
  248.         MOVE.L (A0)+,$134.W
  249.         BSET.B #3,$FFFFFA17.W
  250.         MOVE #$2300,SR
  251.         MOVEQ #$11,D0            ; resume
  252.         BSR Writeikbd        
  253.         MOVEQ #$8,D0            ; restore mouse.
  254.         BSR Writeikbd
  255.         BSR flush
  256.         RTS
  257.  
  258. ;--------------------------------------------------------------------------
  259. ; CookieJar Check to see if we have DMA sound.(i.e STE/TT)
  260. ; Return D1=0 if DMA sound is not available on this machine. (else d1=-1)
  261. ;--------------------------------------------------------------------------
  262.  
  263. SoundTest    move.l $5A0.W,d0        ; get cookie jar ptr
  264.         beq.s no_dmasnd            ;; nul ptr = no cookie jar
  265.         move.l d0,a0            ;; (no cookie jar= no dma snd)
  266. .search_next    tst.l (a0)            
  267.         beq.s no_dmasnd
  268.         cmp.l #'_SND',(a0)        ; cookie found?
  269.         beq.s .search_found
  270.         addq.l #8,a0
  271.         bra.s .search_next
  272. .search_found    move.l 4(a0),d0            ; get _SND const.
  273.         cmp.l #3,D0
  274.         blt.s no_dmasnd
  275.         moveq #-1,d1            ; DMA SOUND FOUND!
  276.         rts
  277. no_dmasnd    moveq #0,d1            ; NO DMA SOUND!
  278.         rts
  279.  
  280. ; Wait for a vbl..
  281.  
  282. Wait_Vbl    MOVE #37,-(SP)
  283.         TRAP #14
  284.         ADDQ.L #2,SP
  285.         RTS
  286.  
  287. ; Wait for a vbl,(Not Gems..)
  288.  
  289. Wait_VblNG    MOVE.W vbl_timer(PC),D0
  290. .waitvb        CMP.W vbl_timer(PC),D0
  291.         BEQ.S .waitvb
  292.         RTS
  293.  
  294. old_stuff:    DS.L 18
  295. oldres        DS.W 1
  296. oldsp        DS.L 1
  297. oldusp        DS.L 1
  298.  
  299. ; Flush IKBD
  300.  
  301. flush        BTST.B #0,$FFFFFC00.W        ; any waiting?
  302.         BEQ.S .flok            ; exit if none waiting.
  303.         MOVE.B $FFFFFC02.W,D0        ; get next in queue
  304.         BRA.S flush            ; and continue
  305. .flok        RTS
  306.  
  307. ; Write d0 to IKBD
  308.  
  309. Writeikbd    BTST.B #1,$FFFFFC00.W
  310.         BEQ.S Writeikbd            ; wait for ready
  311.         MOVE.B D0,$FFFFFC02.W        ; and send...
  312.         RTS
  313.  
  314. ; Keyboard handler interrupt routine...
  315. ; (crap)
  316.  
  317. key_rout    PEA (A0)
  318.         MOVE D0,-(SP)
  319.         MOVE.B $FFFFFC00.W,D0
  320.         BTST #7,D0            ; int req?
  321.